import Vue from "vue";
import VueRouter from "vue-router";

Vue.use(VueRouter);


// 因$router.push返回Promise函数 缺少回调会在控制台报错，添加以下代码
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location, onResolve, onReject) {
  if (onResolve || onReject) return originalPush.call(this, location, onResolve, onReject)
  return originalPush.call(this, location).catch(err => err)
}

const routers = [
  {
    path: "/",
    name: "AdminHome",
    redirect: 'home',
    component: () => import("@/views/AdminHome.vue"),
    children: [
      // {
      //   path: "/home",
      //   name: "home",
      //   component: () => import("@/views/home/index.vue"),
      // },
      // {
      //   path: "/user",
      //   name: "user",
      //   component: () => import("@/views/user/index.vue"),
      // },
      // {
      //   path:'/mall',
      //   name:'mall',
      //   component: () => import("@/views/mail/index.vue")
      // },
      // {
      //   path:'/page1',
      //   name:'page1',
      //   component: () => import("@/views/other/pageOne.vue")
      // },
      // {
      //   path:'/page2',
      //   name:'page2',
      //   component: () => import("@/views/other/pageTwo.vue")
      // }
    ],
  },
  {
    path:'/login',
    name:'login',
    component: ()=> import('@/views/login/Login.vue')
  }
];

const router = new VueRouter({
  mode: "history",
  routes: routers,
});

export default router;
